************************************************************
**** 	Table A11: HETEROGENEITY BY WORRIES 		****
************************************************************



use "$dir/Data/analysis_main.dta", clear

gen blworryn = (future_fin_worry==1 | future_fin_worry==2) if !mi(future_fin_worry)
gen blworryn_miss = mi(future_fin_worry) if survsample==1
	replace blworryn = 0 if inlist(round,3,5) & survsample==1

eststo clear

cap drop *_wn
cap drop *_wmiss
cap drop *_hiw
foreach y of varlist cash_postpay cash_announce{
	gen `y'_wn = blworryn*`y'
	gen `y'_wmiss = blworryn_miss*`y'
	gen `y'_hiw = wealth_hi_avg*`y'

}	

	eststo: reghdfe n_productivity cash_postpay cash_announce cash_postpay_wn cash_announce_wn cash_postpay_wmiss cash_announce_wmiss blworryn blworryn_miss blhrprod blhrprodsq blhrprod_miss bs_labor_30_miss future_fin_worry_miss i.pd if pd>0 & survsample==1, vce(cl pid) absorb(roundgroup)
	qui lincom cash_postpay + cash_postpay_wn
	qui estadd scalar coef1 = r(estimate)
	qui estadd scalar se1 = r(se)					
	qui estadd scalar pval1 = 2*ttail(r(df),abs(r(estimate)/r(se)))

	eststo: reghdfe n_productivity cash_postpay cash_announce cash_postpay_wn cash_announce_wn cash_postpay_hiw cash_announce_hiw wealth_hi_avg cash_postpay_wmiss cash_announce_wmiss blworryn blworryn_miss blhrprod blhrprodsq blhrprod_miss bs_labor_30_miss future_fin_worry_miss i.pd if pd>0 & survsample==1, vce(cl pid) absorb(roundgroup)
	qui lincom cash_postpay + cash_postpay_wn
	qui estadd scalar coef1 = r(estimate)
	qui estadd scalar se1 = r(se)					
	qui estadd scalar pval1 = 2*ttail(r(df),abs(r(estimate)/r(se)))
	qui lincom cash_postpay + cash_postpay_hiw
	qui estadd scalar coef2 = r(estimate)
	qui estadd scalar se2 = r(se)					
	qui estadd scalar pval2 = 2*ttail(r(df),abs(r(estimate)/r(se)))	
	
	
	eststo: reghdfe att_ind cash_postpay cash_announce cash_postpay_wn cash_announce_wn cash_postpay_wmiss cash_announce_wmiss blworryn blworryn_miss blatt blatt_miss blhrprod_miss read_odiya_nm read_odiya_miss bs_labor_30_miss future_fin_worry_miss i.pd if pd>0 & survsample==1, vce(cl pid) absorb(roundgroup)
	qui lincom cash_postpay + cash_postpay_wn
	qui estadd scalar coef1 = r(estimate)
	qui estadd scalar se1 = r(se)					
	qui estadd scalar pval1 = 2*ttail(r(df),abs(r(estimate)/r(se)))

	eststo: reghdfe att_ind cash_postpay cash_announce cash_postpay_wn cash_announce_wn cash_postpay_hiw cash_announce_hiw wealth_hi_avg cash_postpay_wmiss cash_announce_wmiss blworryn blworryn_miss blatt blatt_miss blhrprod_miss read_odiya_nm read_odiya_miss bs_labor_30_miss future_fin_worry_miss i.pd if pd>0 & survsample==1, vce(cl pid) absorb(roundgroup)
	qui lincom cash_postpay + cash_postpay_wn
	qui estadd scalar coef1 = r(estimate)
	qui estadd scalar se1 = r(se)					
	qui estadd scalar pval1 = 2*ttail(r(df),abs(r(estimate)/r(se)))
	qui lincom cash_postpay + cash_postpay_hiw
	qui estadd scalar coef2 = r(estimate)
	qui estadd scalar se2 = r(se)					
	qui estadd scalar pval2 = 2*ttail(r(df),abs(r(estimate)/r(se)))	
	
label var cash_postpay "Cash $\times$ Post-pay" 
label var cash_postpay_wn "Cash $\times$ Post-pay $\times$ Not worried" 
label var cash_postpay_hiw "Cash $\times$ Post-pay $\times$ Higher wealth" 


#delimit ;
local tablerow cash_postpay cash_postpay_wn cash_postpay_hiw;

esttab using "$oa/$t/Table_A11.tex", 
    b(3) se booktabs star(* .1 ** .05 *** .01) nonotes nomtitles  
    replace label style(tex) gaps keep(`tablerow') order(`tablerow') 
    stats(coef1 se1 pval1 coef2 se2 pval2 N, labels("Coef: cash effect + worry interaction" "SE: cash effect + worry interaction" "P-val: cash effect + worry interaction" "Coef: cash effect + wealth interaction" "SE: cash effect + wealth interaction" "P-val: cash effect + wealth interaction" "N: worker-hours") fmt(%9.3fc  %9.3fc  %9.3fc  %9.3fc %9.3fc  %9.3fc %9.0fc)) 
	prehead("{\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} \begin{tabular}     {@{\extracolsep{4pt}}l*{10}{>{\centering\arraybackslash}m{2.5cm}}@{}}      \toprule    
	& \multicolumn{2}{c}{\textbf{Hourly production}}  & \multicolumn{2}{c}{\textbf{Attentiveness index}} \bigstrut  \\ 
	\cline{2-3} \cline{4-5} \addlinespace 
	") ;
#delimit cr	
